#include <op/op.hpp>
#include <add/add.hpp>
#include <sub/sub.hpp>
#include <iostream>

namespace test::op
{
    int op(char c, int x, int y)
    {
        int r = 0;
        switch (c) {
        case '+': r = add::op(x, y); break;
        case '-': r = sub::op(x, y); break;
        default: break;
        }
        return r;
    }

    namespace
    {
        class impl : public op
        {
            const char c;

        public:
            impl(char c) : c(c) {}

            int operator()(int x, int y) override
            {
                return test::op::op(c, x, y);
            }
        };
    }



    std::shared_ptr<class op> op::create(char c)
    {
        return std::make_shared<impl>(c);
    }
}
